package com.dk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dk.pojo.Part;
import com.dk.mapper.PartMapper;
import com.dk.service.IPartService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2022-07-08
 */
@Service
public class PartServiceImpl extends ServiceImpl<PartMapper, Part> implements IPartService {

    @Autowired
    private PartMapper partMapper;
    @Override
    public IPage<Part> getPartList(Page<Part> page, String name,String status) {

        QueryWrapper<Part> queryWrapper=new QueryWrapper<>();
        if (!StringUtils.isEmpty(name)){
            queryWrapper.like("name",name);
        }
        if (!StringUtils.isEmpty(status)){
            queryWrapper.eq("status",status);
        }
        return partMapper.selectPage(page,queryWrapper);
    }
}
